import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/Home.vue'
import Literature from '@/views/Literature.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: {
      title: '瓷之魂 - 主页'
    }
  },
  {
    path: '/literature',
    name: 'Literature',
    component: Literature,
    meta: {
      title: '瓷之魂 - 文献详情'
    }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router 